<?php

namespace App\Models\Blog;

use Illuminate\Database\Eloquent\Model;

class Gallery extends Model
{
    Protected $guarded = [];

    //每个相册有很多照片
    public function photos()
    {
        return $this->hasMany('App\Models\Blog\Photo');
    }

    /**
     * 检查相册里面是否有照片
     * @param $id
     * @return bool
     */
    static function check_photo($id)
    {
        $gallery = self::with('photos')->find($id);
        if ($gallery->photos->isEmpty()) {
            return true;
        }

        return false;
    }
}
